//
//  MineSettingViewController.m
//  baodongPro
//
//  Created by feng on 16/2/29.
//  Copyright © 2016年 proper. All rights reserved.
//

#import "MineSettingViewController.h"
#import <FBDTools/ShowAlertTool.h>
#import "AppDelegate.h"

@interface MineSettingViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong)UITableView* settingTable;
@end

@implementation MineSettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    _settingTable=[[UITableView alloc] initWithFrame:CGRectMake(0, 64, ScreenW, ScreenH-64) style:UITableViewStylePlain];
    _settingTable.delegate=self;
    _settingTable.dataSource=self;
    [self.view addSubview:_settingTable];
    
    
    
    
}
#pragma mark ---UITableViewDataSource&&UITableViewDelegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString* indetifier=@"MyCells";
    UITableViewCell*cell=[tableView dequeueReusableCellWithIdentifier:indetifier];
    if (!cell)
    {
        cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indetifier ];

        cell.selectionStyle=0;
        cell.textLabel.textAlignment=NSTextAlignmentCenter;
        cell.textLabel.text=@"退出登录";
    }
    

    
    return cell;
    
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    
    [self  appLoginOutForCurrentUser];
    
    
}


-(void)appLoginOutForCurrentUser
{
        [ShowAlertTool showConfigeWithTitle:@"温馨提示" Message:@"您确定要退出吗？" ButtonTitleArray:@[@"退出",@"取消"]];
        [[ShowAlertTool defaultTool]showInVC:self sureBlcok:^(UIAlertAction *oneAction) {
            [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeBlack];
            [SVProgressHUD showWithStatus:@"退出中" ];
            
            EMError *error = [[EMClient sharedClient] logout:YES];
            if (!error) {
                
                NSLog(@"退出成功");
            }else
            {
                NSLog(@"退出登录失败：%@",error.errorDescription);
            }

        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [AppDelegate appLoginOutForCurrentUser];
            [SVProgressHUD dismiss];
            });
    
        } failedBlock:^(UIAlertAction *oneAction) {

            
        }];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
